﻿using UnityEngine;
using System.Collections;

public class link : MonoBehaviour {

	public bool door;
	public bool obstacle;
	[HideInInspector] public bool dooractive;

	public door doorScript;
	public obstacleLink obstacleScript;

	public ButtonLine line;

	// Use this for initialization
	void Start () {

		if(dooractive==true)
		{
			line.obstacles = new GameObject[line.a+1];
			line.obstacles[line.a] = doorScript.gameObject;
			line.a++;
		}
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public void go ()
	{
		if(door == true)
		{
			Debug.Log("go to door");
			Debug.DrawLine(transform.position,doorScript.transform.position,Color.red,duration:20f);
			doorScript.activateDoor();
			line.target = doorScript.gameObject;
			line.lineOn=true;
		}
		if(obstacle == true)
		{
			Debug.Log("go to obstacle");
			obstacleScript.randomDoor();
		}
	}	
}
